const db = require('../config/db')
const {DataTypes} = require('sequelize');
const attributes = {
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,            // 主键
        autoIncrement: true,         // 自动递增
    },
    user_number: {
        type: DataTypes.STRING(11),
        allowNull: false,
        unicode: true,
        primaryKey: true,
        unique: true,
        comment: '用户账号'
    },
    user_name: {
        type: DataTypes.STRING(18),
        allowNull: false,
        comment: '用户用户昵称'
    },
    password: {
        type: DataTypes.STRING(155),
        allowNull: false,
        comment: '用户密码'
    },
    user_role: {
        type: DataTypes.STRING(18),
        allowNull: false,
        comment: '用户权限'
    },
    user_sex: {
        type: DataTypes.STRING(1),
        allowNull: true,
        comment: '用户性别'
    },
    user_introduce: {
        type: DataTypes.STRING(),
        allowNull: true,
        comment: '自我介绍'
    },
    user_photo_url: {
        type: DataTypes.STRING(),
        allowNull: true,
        comment: '用户头像地址'
    },
    user_background_img: {
        type: DataTypes.STRING(),
        allowNull: true,
        comment: '用户背景地址'
    },
    user_background_music: {
        type: DataTypes.STRING(),
        allowNull: true,
        comment: '背景音乐'
    },
    user_phone: {
        type: DataTypes.STRING(11),
        allowNull: true,
        comment: '用户手机号码'
    },
    user_email: {
        type: DataTypes.STRING(100),
        allowNull: true,
        comment: '用户邮箱'
    },
    user_blacklist: {
        type: DataTypes.STRING(1),
        allowNull: true,
        comment: '拉黑0没有拉黑 1拉黑'
    },

}


const User = db.define('blog_users', attributes)

// User.hasMany(blogCommentModel)
// User.sync()

module.exports = User
